<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    import="java.sql.*" errorPage=""
    %>
    <%@taglib uri="/struts-tags"  prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src = "./scripts/jquery.js"></script>
<script type="text/javascript" src = "./scripts/jquery-ui.js"></script>
</head>
<body>

<h3>Add New Record</h3>
<s:actionerror/>

<s:form action="add.action" validate="true">
<s:textfield name="contact.firstName" label="Firstname" required="true" />
<s:textfield name="contact.lastName" label="Lastname" required="true" />
<s:textfield name="contact.emailId" label="Email" id="email" onchange="checkEmail()"/>
<s:textfield name="contact.cellNo" label="Cell No."/>
<s:textfield name="contact.website" label="Homepage"/>
<s:textfield name="contact.birthDate" label="Birthdate"/> 
<s:select label="Contact Type" list="contactList"
listKey="contactType" listValue="contactType"
name="chooseContactType" headerKey="-1"
headerValue="-- Please Select --" required="true"/>
<s:textfield name="contact.contactManager" label="Manager" id="selected" readonly="true"/> <a href=" #" id="popup">Lookup</a>
<input type="checkbox" name="checkbox" id="checkbox" onclick="check()"> Is Active?
<s:hidden name="contact.isActive" id="isActive"/>
<s:submit value="Add Contact" align="center" onclick="checkBlank()"/>
</s:form>
<input type="button" value="Back">
<script type="text/javascript">
function backPage(){
	if(!isValidEmailAddress($("#email").val())){
		alert("invalid");
	}else{
		alert("valid");
	}
}

$(function(){
	 $("#popup").click(function(){
		
		 window.open("index.jsp","_blank","width=400,height=345");
			ev.preventDefault();
	 });
	 
});

function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
    return pattern.test(emailAddress);
}
function checkEmail(){
	if(!isValidEmailAddress($("#email").val())){
		//alert("invalid");
	}else{
		//alert("valid");
	}
}
function check(){
	if($("#checkbox").is(':checked')){
		$("#isActive").val("YES");}else{
			$("#isActive").val("NO");
		}
	
}



$(document).ready(
		function() {
			$("#isActive").val("NO");
		});

</script>
</body>
</html>